-- =============================================
-- 需求描述: 根据所给方式，将层级关系（省-市-区）展开为横向的三列显示
-- =============================================


CREATE TABLE dbo.G250910
(
    ID       INT,
    NAME     VARCHAR(50),
    ParentId INT
)
go


INSERT INTO demo.dbo.G250910 (ID, NAME, ParentId) VALUES (1, N'北京市', 0);
INSERT INTO demo.dbo.G250910 (ID, NAME, ParentId) VALUES (2, N'广东省', 0);
INSERT INTO demo.dbo.G250910 (ID, NAME, ParentId) VALUES (3, N'昌平区', 1);
INSERT INTO demo.dbo.G250910 (ID, NAME, ParentId) VALUES (4, N'海淀区', 1);
INSERT INTO demo.dbo.G250910 (ID, NAME, ParentId) VALUES (5, N'广州市', 2);
INSERT INTO demo.dbo.G250910 (ID, NAME, ParentId) VALUES (6, N'深圳市', 2);
INSERT INTO demo.dbo.G250910 (ID, NAME, ParentId) VALUES (7, N'沙河镇', 3);
INSERT INTO demo.dbo.G250910 (ID, NAME, ParentId) VALUES (8, N'中关村', 4);
INSERT INTO demo.dbo.G250910 (ID, NAME, ParentId) VALUES (9, N'天河区', 5);
INSERT INTO demo.dbo.G250910 (ID, NAME, ParentId) VALUES (10, N'福田区', 6);
INSERT INTO demo.dbo.G250910 (ID, NAME, ParentId) VALUES (11, N'广西壮族自治区', 0);
INSERT INTO demo.dbo.G250910 (ID, NAME, ParentId) VALUES (10, N'南宁市', 11);